libobs_simple\sources\linux\sources/
x11_capture.rs

1use libobs_wrapper::{
2    data::StringEnum,
3    sources::{ObsSourceBuilder, ObsSourceRef},
4};
5
6use crate::sources::macro_helper::define_object_manager;
7
8#[derive(Clone, Copy, Debug, PartialEq, Eq)]
9/// Describes the X11 capture server type
10pub enum ObsX11ServerType {
11    /// Local X11 server
12    Local,
13    /// Custom X11 server
14    Custom,
15}
16
17impl StringEnum for ObsX11ServerType {
18    fn to_str(&self) -> &str {
19        match self {
20            ObsX11ServerType::Local => "local",
21            ObsX11ServerType::Custom => "custom",
22        }
23    }
24}
25
26define_object_manager!(
27    #[derive(Debug)]
28    /// A source to capture X11 screen/window content.
29    ///
30    /// This source provides screen capture functionality on Linux systems running X11.
31    /// It can capture the entire screen or specific areas with cropping options.
32    struct X11CaptureSource("xshm_input") for ObsSourceRef {
33        /// Screen/Display to capture
34        #[obs_property(type_t = "int")]
35        screen: i64,
36
37        /// Whether to show the cursor in the capture
38        #[obs_property(type_t = "bool")]
39        show_cursor: bool,
40
41        /// Enable advanced settings
42        #[obs_property(type_t = "bool")]
43        advanced: bool,
44
45        /// X Server to connect to (when using advanced settings)
46        #[obs_property(type_t = "string")]
47        server: String,
48
49        /// Crop from top (in pixels)
50        #[obs_property(type_t = "int")]
51        cut_top: i64,
52
53        /// Crop from left (in pixels)
54        #[obs_property(type_t = "int")]
55        cut_left: i64,
56
57        /// Crop from right (in pixels)
58        #[obs_property(type_t = "int")]
59        cut_right: i64,
60
61        /// Crop from bottom (in pixels)
62        #[obs_property(type_t = "int")]
63        cut_bot: i64,
64    }
65);
66
67impl ObsSourceBuilder for X11CaptureSourceBuilder {}